<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Object学习</title>
</head>
<script>
    function Shape() {
        this.x = 0;
        this.y = 0;
    }

    Shape.prototype.move = function (x, y) {
        this.x += x;
        this.y += y;
        console.info('Shape moved.');
    }


    function Rectangle() {
        Shape.call(this);
    }

    Rectangle.prototype = Object.create(Shape.prototype);
    Rectangle.prototype.constructor = Rectangle;

    var rect = new Rectangle();

    console.log('Is rect an instance of Rectangle?',
        rect instanceof Rectangle); // true
    console.log('Is rect an instance of Shape?',
        rect instanceof Shape); // true
    rect.move(1, 1); // Outputs, 'Shape moved.'


</script>

<body>

</body>

</html>